﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<PagedList<Pulog.Models.Post>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

<%foreach (Pulog.Models.Post p in this.ViewData.Model)
      { %>
    
        <article class="post">
              <h3><a href="/Posts/Show/<%=p.postID.ToString()%>"><%=p.title%></a></h3>

            <%--<div class="tags">
             <ul>
                <li class="label">Tags:</li>
                <%if (p.taPostTags == null || p.PostTags.Count == 0)
                  {%>
                <li><a href="/tag/uncategorized">Uncategorized</a></li>
                <%}
                  else
                  {
                      for (int i = 0; i < p.PostTags.Count - 1; i++ )
                      {
                %>
                        <li><a href="/tag/<%=p.PostTags[i].Tag.TagName%>"><%=p.PostTags[i].Tag.TagName%></a>,</li>    
                 <%   } %>
                      <li><a href="/tag/<%=p.PostTags[p.PostTags.Count - 1].Tag.TagName%>"><%=p.PostTags[p.PostTags.Count - 1].Tag.TagName%></a></li>
                 <% } %>       
             </ul>
            </div>--%>
            
            <footer class="postmeta">作者:<%=p.User.userName %> 发表于:<%=p.pubTime.ToString("yyyy年MM月dd日")%> -- <%=Helper.GetDateDifference(p.pubTime)%> | 分类: <a href="/Category/<%=p.Category.categoryName%>"><%=p.Category.categoryName%></a>
            | <a href="/Posts/Show/<%=p.postID.ToString()%>#comments">Comments: <%=p.Comments.Count %></a> | Views: <%=p.views %></footer> <!-- end post meta -->
<%--            | Tags: <%foreach (Pulog.Models.PostTag t in p.PostTags.ToList())
              {%>
                  <a href="/Tags/<%=t.Tag.TagName %>"><%= t.Tag.TagName %></a>,
              <%} %>--%>
              
            <%--分类:<%foreach(Pulog.Models.PostCategory cat in p.PostCategories){%><%=cat.Category.categoryName;}%>--%>
 
                <p>
                    <%=p.content%>
                </p>
        
            <%--<div class="commentlink">
            <% if (p.Comments == null || p.Comments.Count == 0)
               { %>
            <a href="/<%=p.Created.ToString("yyyy/MM/dd") %>/<%=p.Title.ToString().Replace(' ','-')%>" title="Comment on <%=p.Title%>">No Comments&#187;</a></p>             
            <%}
               else
               {%>
            <a href="/<%=p.Created.ToString("yyyy/MM/dd") %>/<%=p.Title.ToString().Replace(' ','-')%>" title="Comment on <%=p.Title%>"><%=p.Comments.Count%> Comments&#187;</a></p>             
            <%} %>
            </div>--%>
  </article>
    <%} %>


    <div id="paging">
        <%--if (Model.IsPreviousPage)
          { %>
            <%=Html.ActionLink("Newer Posts", "Index", new { page = ViewData.Model.PageIndex - 1 })%>&nbsp;&nbsp;
        <%} %>
        <%if (Model.IsNextPage)
          { %>
            <%=Html.ActionLink("Older Posts", "Index", new { page = ViewData.Model.PageIndex + 1 })%>
        <%} --%>
        
        
        <%--
            int currentPage = Model.PageIndex.Value;

            int recordCount = Model.TotalCount;
            int? pageSize = Model.PageSize;
            int splitSize = 8;

            StringBuilder sb = new StringBuilder();
            int pagecount = recordCount % pageSize.Value == 0 ? recordCount / pageSize.Value : recordCount / pageSize.Value + 1;
            if (currentPage < 1)
                currentPage = 1;
            if (currentPage > pagecount)
                currentPage = pagecount;
            int startpage = currentPage % splitSize == 0 ? currentPage - (currentPage - 1) % splitSize : currentPage - (currentPage % splitSize) + 1;
            int endpage = startpage + splitSize - 1;
            if (endpage > pagecount)
                endpage = pagecount;
            ViewContext.RouteData.Values.Remove("id");
            sb.AppendLine("<div class=\"lpage_main\">");
            sb.AppendLine("<script type=\"text/javascript\">");
            sb.AppendLine("//<!--");
            sb.AppendLine("function lpage_change(){");
            sb.AppendLine("var lpage_input=document.getElementById(\"lpage_inputbox\");");
            sb.AppendFormat("var url=\"{0}\";\r\n", Url.RouteUrl(ViewContext.RouteData.Values));
            sb.AppendFormat("url=url + '/' + lpage_input.value;\r\n");
            sb.AppendLine("window.location=url;");
            sb.AppendLine("}");
            sb.AppendLine("//-->");
            sb.AppendLine("</script>");
            sb.AppendLine("<div class=\"lpage_list\">");
            sb.AppendLine("<ul>");
            if (currentPage != 1)
            {
                ViewContext.RouteData.Values["id"] = 1;
                sb.AppendFormat("<li><a href=\"{0}\"><img src=\"{1}\" alt=\"首页\" /></a></li>\r\n", Url.RouteUrl(ViewContext.RouteData.Values),"");
            }
            if (currentPage > splitSize)
            {
                ViewContext.RouteData.Values["id"] = currentPage - splitSize;
                sb.AppendFormat("<li><a href=\"{0}\"><img src=\"{1}\" alt=\"前{2}页\" /></a></li>\r\n", Url.RouteUrl(ViewContext.RouteData.Values),"", splitSize);
            }
            for (int page = startpage; page <= endpage; page++)
            {
                if (page == currentPage)
                    sb.AppendFormat("<li id=\"lpage_list_checked\"><a>{0}</a></li>\r\n", page);
                else
                {
                    ViewContext.RouteData.Values["id"] = page;
                    sb.AppendFormat("<li><a href=\"{0}\" title=\"第{1}页\">{1}</a></li>\r\n", Url.RouteUrl(ViewContext.RouteData.Values), page);
                }
            }
            if (endpage < pagecount)
            {
                ViewContext.RouteData.Values["id"] = currentPage + splitSize;
                sb.AppendFormat("<li><a href=\"{0}\"><img src=\"{1}\" alt=\"后{2}页\" /></a></li>\r\n", Url.RouteUrl(ViewContext.RouteData.Values),"", splitSize);
            }
            if (currentPage != pagecount)
            {
                ViewContext.RouteData.Values["id"] = pagecount;
                sb.AppendFormat("<li><a href=\"{0}\"><img src=\"{1}\" alt=\"末页\" /></a></li>\r\n", Url.RouteUrl(ViewContext.RouteData.Values),"");
            }
            sb.AppendLine("</ul>");
            sb.AppendFormat("<div class=\"lpage_input\"><input type=\"text\" id=\"lpage_inputbox\" name=\"lpage_inputbox\" maxlength=\"6\" value=\"{0}\" /></div>\r\n", currentPage);
            sb.AppendLine("<div class=\"lpage_submit\"><input type=\"button\" name=\"lpage_submit\" value=\"GO\" onclick=\"lpage_change();\" /></div>");
            sb.AppendFormat("<div class=\"lpage_info\">{0} {1}/{2} 页</div>\r\n", recordCount, currentPage, pagecount);
            sb.AppendLine("</div>");
            sb.AppendLine("</div>");
            ViewContext.RouteData.Values["id"] = currentPage.ToString();
            Response.Write(sb.ToString());
            --%>
            
      <%Html.RenderPartial("~/Views/Shared/Pagination.ascx", new PagedList<Pulog.Models.Post>(new Pulog.Models.PulogDataContext().Posts,Model.PageIndex.Value,10));%>  
            

    </div>

</asp:Content>





<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
    <title><%=Helper.BlogName %> : <%=Helper.BlogDescription %></title>
</asp:Content>

